package com.manager.service.impl;

import com.manager.bean.Dormitory;
import com.manager.bean.DormitoryExample;
import com.manager.bean.PageInfo;
import com.manager.mapper.DormitoryMapper;
import com.manager.service.DormitoryService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Dormitory)表服务实现类
 *
 * @author makejava
 * @since 2021-03-02 11:00:24
 */
@Service("dormitoryService")
public class DormitoryServiceImpl implements DormitoryService {
    @Resource
    private DormitoryMapper dormitoryDao;


    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public Dormitory queryById(Integer id) {
        return this.dormitoryDao.selectByPrimaryKey(id);
    }



    /**
     * 新增数据
     *
     * @param dormitory 实例对象
     * @return 实例对象
     */
    @Override
    public Dormitory insert(Dormitory dormitory) {
        this.dormitoryDao.insert(dormitory);
        return dormitory;
    }

    /**
     * 修改数据
     *
     * @param dormitory 实例对象
     * @return 实例对象
     */
    @Override
    public Dormitory update(Dormitory dormitory) {
        this.dormitoryDao.updateByPrimaryKey(dormitory);
        return this.queryById(dormitory.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.dormitoryDao.deleteByPrimaryKey(id) > 0;
    }
}
